package com.springcloud.sc.ucpv5.client.application.message.type.intType;

import java.nio.ByteBuffer;

import com.springcloud.sc.ucpv5.client.application.util.UnsignedNumberConvert;

/**
 * 无符号整型
 * 
 */
public class UnInt_Wrap extends IntWrapPublic {

    /**
     * 组包无符号整型
     * 
     * @param buffer
     * @param value
     * @param key
     *            包含所有该类型所需的属性条件
     */
    public static byte[] packUnInt(int value, int length, boolean isOrder) {
	int tInt = value;
	return packUnIntPublic(tInt, length, isOrder);
    }

    /**
     * 解包无符号整型,从缓存里取出四个字节的数据，如果指定长度大于4，则抛弃多余长度的字节
     * 
     * @param buffer
     * @param key
     *            包含所有该类型所需的属性条件
     */
    public static String unpackUnInt(ByteBuffer buffer, int length, boolean isOrder) {
	ByteBuffer tempBuffer = unpackIntPublic(buffer, length, isOrder);
	int tInt = tempBuffer.getInt(0);

	long tLong = UnsignedNumberConvert.getUnsignedIntegerInBytes(tInt);

	return String.valueOf(tLong);
    }

}
